import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Scanner;

public class ScoreMain {

    public static void main(String[] args) {
        HashMap<String, Integer> studentScoreMap = getUserInput();
        check(studentScoreMap);
    }
    private static HashMap<String, Integer> getUserInput() {
        HashMap<String, Integer> studentScoreMap = new LinkedHashMap<>();

        Scanner scanner = new Scanner(System.in);
        while (true) {
            String line = scanner.nextLine();
            if (line.isEmpty()) {
                break;
            }
            String name = line.split(" ")[0];
            int score = Integer.parseInt(line.split(" ")[1]);
            studentScoreMap.put(name, score);
        }

        return studentScoreMap;
    }


    private static void check(HashMap<String, Integer> studentScoreMap) {
        System.out.print("Passed students: ");
        for (String name : studentScoreMap.keySet()) {
            if (studentScoreMap.get(name) >= 50) {
                System.out.print(name + " ");
            }
        }
        System.out.println();

        System.out.print("Failed students: ");
        for (String name : studentScoreMap.keySet()) {
            if (studentScoreMap.get(name) < 16) {
                System.out.print(name + " ");
            }
        }
        System.out.println();
    }
}
